﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PhantomMvvmToolkitTester
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            DataContextChanged += MainPageDataContextChanged;
            DataContext = new MainPageViewModel();
        }

        private void MainPageDataContextChanged(object sender, EventArgs e)
        {
            Debug.WriteLine("MainPageDataContextChanged Fired");
        }

        private void TextBoxTextChanged(object sender, TextChangedEventArgs e)
        {
            ((TextBox)sender).GetBindingExpression(TextBox.TextProperty).UpdateSource();
        }

        public event EventHandler DataContextChanged;

        public void InvokeDataContextChanged(EventArgs e)
        {
            if (DataContextChanged != null)
                DataContextChanged.Invoke(this, e);
        }
    }
}
